* regressions_informal_idom_wages_industry.do	JEP	04/29/15
* Does regressions for mean monthly wages
* Monthly wages
* Exclude some industries
* Do regressions by city - industry
* Include domestic

*************************** Change log ********************************** 

/*
	
*/	

clear 
version 13.1

* Project info
cap project, doinfo
if _rc==198 {
	if c(os)=="Unix" loc master "/home/jperez/AA_Minimum_Wage" 
 else if c(username)=="J16339" loc master "B:\Col_Minimum_Wage"
	else loc master "C:/Users/jorpp/Dropbox (Brown)/Col_Minimum_Wage"
 loc pr = 0
}
else {
	local master "`r(pdir)'"
	local doname "`r(dofile)'"  
 loc pr = 1
	* Project calls
	project, uses("`master'/Data/Source/ocupados_mw.dta")
	* Call programs
	project, relies_on("`master'/Code/Est/sample_choice.do")
	project, relies_on("`master'/Code/Est/build_mw_measures.do")
	project, relies_on("`master'/Code/Est/build_treatment.do")
	project, relies_on("`master'/Code/Est/export_ols.do")
	project, relies_on("`master'/Code/Est/confirmedrunolsols.do")	
}
*/


* Call necessary programs. I do not call using project to carry the programs around. I do not put these in the ado/personal folder because they are specific to the project. They are not ado files.
do "`master'/Code/Est/sample_choice.do"
do "`master'/Code/Est/build_mw_measures.do"
do "`master'/Code/Est/build_treatment.do"
do "`master'/Code/Est/export_ols.do"
do "`master'/Code/Est/confirmedrunols.do"


use "`master'/Data/Source/ocupados_mw.dta", clear

* Number of bootstraps
glo boot=10

* Choose sample
mysample w11sample , hmin(30) hmax(50) sex(0) edadm(65) wage(salario) informal domestic exind(13,29,42)
* Build mw measures
mw_measures w11sample , stub(w11)
* Build treatment
mytreatment, posts("tq(1999q1)") mw(bite_w11_ind) wage(salario_mensual_real)

* RIF regressions

* Create estimation results folder if it doesn't already exist
cap mkdir "`master'/Ster"
cap mkdir "`master'/Ster/w11_new_ind"

* For these I'm going to assume the clusters are the city - industry pairs. This assumes that there is not correlation within city across industries, only within those pairs. Could also run with the standard clustering by city, but that would mean that I'm not really increasing the sample size by running within industry.

* The number of clusters is large  enough that I don't need the full CGM framework, can run just with cluster
egen city_ind=group(ccode cactividad_empresa)
if `pr'!=0 loc reg="register"
else loc reg ""

* Notice differences with rifs. Only one table for all specs, therefore only one name. First goes with replace, others with append.
loc name "`master'/Ster/w11_new_ind/regw_tq(1999q1)_bite_salario_mensual_real_50_edom_ind"

* Panel A. Employment
confirmedrunols, `reg' controls() name(`name') ctitle(emp) ster(`master'/Ster/w11_new_ind/reg_emp_tq(1999q1)_bite_salario_mensual_real_50_edom_ind) rif(w11A)  r(replace) sample(w11sample) fe(i.ccode#i.cactividad_empresa i.time) cluster(city_ind) large 
* Panel B. Employment and Bartik Price Variable
confirmedrunols, `reg' controls(bartikp1_ex) name(`name') ctitle(emp_bp) ster(`master'/Ster/w11_new_ind/reg_emp_bp_tq(1999q1)_bite_salario_mensual_real_50_edom_ind) rif(w11B)  r(append) sample(w11sample) fe(i.ccode#i.cactividad_empresa i.time) cluster(city_ind) large  
* Panel C. Employment and Bartik Quantity Variable
confirmedrunols, `reg' controls(bartikq_ex) name(`name') ctitle(emp_bq) ster(`master'/Ster/w11_new_ind/reg_emp_bq_tq(1999q1)_bite_salario_mensual_real_50_edom_ind) rif(w11C)  r(append) sample(w11sample) fe(i.ccode#i.cactividad_empresa i.time) cluster(city_ind) large  
* Panel D. Employment and City Trends
confirmedrunols, `reg' controls(i.ccode#c.trend ) name(`name') ctitle(sst_emp) ster(`master'/Ster/w11_new_ind/reg_sst_emp_tq(1999q1)_bite_salario_mensual_real_50_edom_ind) rif(w11D)  r(append) sample(w11sample) fe(i.ccode#i.cactividad_empresa i.time) cluster(city_ind) large 
* Panel E. Employment, Bartik Price Variable and City Trends
confirmedrunols, `reg' controls(i.ccode#c.trend bartikp1_ex) name(`name') ctitle(sst_emp_bp) ster(`master'/Ster/w11_new_ind/reg_sst_emp_bp_tq(1999q1)_bite_salario_mensual_real_50_edom_ind) rif(w11E)  r(append) sample(w11sample) fe(i.ccode#i.cactividad_empresa i.time) cluster(city_ind) large  
* Panel F. Employment, Bartik Quantity Variable and City Trends
confirmedrunols, `reg' controls(i.ccode#c.trend bartikq_ex) name(`name') ctitle(sst_emp_bq) ster(`master'/Ster/w11_new_ind/reg_sst_emp_bq_tq(1999q1)_bite_salario_mensual_real_50_edom_ind) rif(w11F)  r(append) sample(w11sample) fe(i.ccode#i.cactividad_empresa i.time) cluster(city_ind) large  
* Panel G. Employment, Bartik Price Variable - Industry fe, city fe and interactions
confirmedrunols, `reg' controls(bartikp1_ex) name(`name') ctitle(emp_bp_ixc) ster(`master'/Ster/w11_new_ind/reg_emp_bp_ixc_tq(1999q1)_bite_salario_mensual_real_50_edom_ind) rif(w11G)  r(append) sample(w11sample) fe(i.ccode##i.cactividad_empresa i.time) cluster(city_ind) large 
* Panel H. Employment, Bartik Quantity Variable and City - Industry fe, city fe and interactions
confirmedrunols, `reg' controls(bartikq_ex) name(`name') ctitle(emp_bq_ixc) ster(`master'/Ster/w11_new_ind/reg_emp_bq_ixc_tq(1999q1)_bite_salario_mensual_real_50_edom_ind) rif(w11H)  r(append) sample(w11sample) fe(i.ccode##i.cactividad_empresa i.time) cluster(city_ind) large 
* Panel I - Employment, Bartik Price Variable - Industry fe, city fe and interactions - City Industry trends
confirmedrunols, `reg' controls(bartikp1_ex) name(`name') ctitle(ct_emp_bp_ixc) ster(`master'/Ster/w11_new_ind/reg_ct_emp_bp_ixc_tq(1999q1)_bite_salario_mensual_real_50_edom_ind) rif(w11I)  r(append) sample(w11sample) fe(i.ccode##i.cactividad_empresa i.ccode#i.cactividad_empresa#c.trend i.time) cluster(city_ind) large 	
* Panel J. Employment, Bartik Quantity Variable and City - Industry fe, city fe and interactions
confirmedrunols, `reg' controls(bartikq_ex) name(`name') ctitle(ct_emp_bq_ixc) ster(`master'/Ster/w11_new_ind/reg_ct_emp_bq_ixc_tq(1999q1)_bite_salario_mensual_real_50_edom_ind) rif(w11J)  r(append) sample(w11sample) fe(i.ccode##i.cactividad_empresa i.ccode#i.cactividad_empresa#c.trend i.time) cluster(city_ind) large 

